package bairui.international.model.domain.jpa;

import com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue;

/**
 *
 * (产品属性项)TB_ProductPropertyItem
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_ProductPropertyItem#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_productPropertyItem")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("产品属性项")
@com.lianjing.sh.processing.info.annotation.InfoComment("产品属性项")
public class TB_ProductPropertyItem
 extends TBSuper_BaseIDAndTimeAndOrderValue
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<Long>,
	com.sh_lianjing.state.HasStatable,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		/** 名称 */
		public String getName();
		/** 状态 */
		public com.lianjing.sh.model.uml.model.status.State_UpDown getState();
		/** 产品属性 */
		public bairui.international.model.domain.jpa.TB_ProductProperty getProductProperty();
		/** 最小值 */
		public Double getMin();
		/** 最大值 */
		public Double getMax();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_ProductPropertyItem properties(MustProperties properties) {
		this.setName(properties.getName());
		this.setState(properties.getState());
		this.setProductProperty(properties.getProductProperty());
		this.setMin(properties.getMin());
		this.setMax(properties.getMax());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_ProductPropertyItem(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
		/** 备注 */
		public String getComment();
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_ProductPropertyItem properties(OptionalSingleProperties properties) {
		this.setComment(properties.getComment());
		return this;
	}
	
	
	
	public TB_ProductPropertyItem(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		/** 名称 */
		public String getName();
		/** 状态 */
		public com.lianjing.sh.model.uml.model.status.State_UpDown getState();
		/** 产品属性 */
		public bairui.international.model.domain.jpa.TB_ProductProperty getProductProperty();
		/** 最小值 */
		public Double getMin();
		/** 最大值 */
		public Double getMax();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_ProductPropertyItem properties(CurrentMustProperties properties) {
		this.setName(properties.getName());
		this.setState(properties.getState());
		this.setProductProperty(properties.getProductProperty());
		this.setMin(properties.getMin());
		this.setMax(properties.getMax());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
		/** 备注 */
		public String getComment();
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_ProductPropertyItem properties(CurrentOptionalSingleProperties properties) {
		this.setComment(properties.getComment());
		return this;
	}
	
	public TB_ProductPropertyItem(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_ProductPropertyItem(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean
	) {
		update(bean);
	}
	
	public TB_ProductPropertyItem update(com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean){
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			Integer orderValue = getOrderValue(TB_ProductPropertyItem.this);
			if(isOverride_getOrderValue){
				TB_ProductPropertyItem.this.setOrderValue(orderValue);
			}
	
			String name = getName(TB_ProductPropertyItem.this);
			if(isOverride_getName){
				TB_ProductPropertyItem.this.setName(name);
			}
	
			String comment = getComment(TB_ProductPropertyItem.this);
			if(isOverride_getComment){
				TB_ProductPropertyItem.this.setComment(comment);
			}
	
			com.lianjing.sh.model.uml.model.status.State_UpDown state = getState(TB_ProductPropertyItem.this);
			if(isOverride_getState){
				TB_ProductPropertyItem.this.setState(state);
			}
	
			bairui.international.model.domain.jpa.TB_ProductProperty productProperty = getProductProperty(TB_ProductPropertyItem.this);
			if(isOverride_getProductProperty){
				TB_ProductPropertyItem.this.setProductProperty(productProperty);
			}
	
			java.util.List<bairui.international.model.domain.jpa.TB_Product> products = getProducts(TB_ProductPropertyItem.this);
			if(isOverride_getProducts){
				TB_ProductPropertyItem.this.setProducts(products);
			}
	
			Double min = getMin(TB_ProductPropertyItem.this);
			if(isOverride_getMin){
				TB_ProductPropertyItem.this.setMin(min);
			}
	
			Double max = getMax(TB_ProductPropertyItem.this);
			if(isOverride_getMax){
				TB_ProductPropertyItem.this.setMax(max);
			}
	
			java.util.List<bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem> productCategoryPropertyItems = getProductCategoryPropertyItems(TB_ProductPropertyItem.this);
			if(isOverride_getProductCategoryPropertyItems){
				TB_ProductPropertyItem.this.setProductCategoryPropertyItems(productCategoryPropertyItems);
			}
		}
	
		public TB_ProductPropertyItem up(){
			return TB_ProductPropertyItem.this;
		}
	
		/** 排序值 */
		private boolean isOverride_getOrderValue = true;
		public Integer getOrderValue(TB_ProductPropertyItem it) throws Exception { 
			isOverride_getOrderValue = false; 
			return null;
		}
		/** 名称 */
		private boolean isOverride_getName = true;
		public String getName(TB_ProductPropertyItem it) throws Exception { 
			isOverride_getName = false; 
			return null;
		}
		/** 备注 */
		private boolean isOverride_getComment = true;
		public String getComment(TB_ProductPropertyItem it) throws Exception { 
			isOverride_getComment = false; 
			return null;
		}
		/** 状态 */
		private boolean isOverride_getState = true;
		public com.lianjing.sh.model.uml.model.status.State_UpDown getState(TB_ProductPropertyItem it) throws Exception { 
			isOverride_getState = false; 
			return null;
		}
		/** 产品属性 */
		private boolean isOverride_getProductProperty = true;
		public bairui.international.model.domain.jpa.TB_ProductProperty getProductProperty(TB_ProductPropertyItem it) throws Exception { 
			isOverride_getProductProperty = false; 
			return null;
		}
		/** 产品 */
		private boolean isOverride_getProducts = true;
		public java.util.List<bairui.international.model.domain.jpa.TB_Product> getProducts(TB_ProductPropertyItem it) throws Exception { 
			isOverride_getProducts = false; 
			return null;
		}
		/** 最小值 */
		private boolean isOverride_getMin = true;
		public Double getMin(TB_ProductPropertyItem it) throws Exception { 
			isOverride_getMin = false; 
			return null;
		}
		/** 最大值 */
		private boolean isOverride_getMax = true;
		public Double getMax(TB_ProductPropertyItem it) throws Exception { 
			isOverride_getMax = false; 
			return null;
		}
		/** 产品分类属性项 */
		private boolean isOverride_getProductCategoryPropertyItems = true;
		public java.util.List<bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem> getProductCategoryPropertyItems(TB_ProductPropertyItem it) throws Exception { 
			isOverride_getProductCategoryPropertyItems = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_ProductPropertyItem() {
	}
	
	public TB_ProductPropertyItem(
		@lombok.NonNull Long id
	) {
		this.setId(id);
	}
	
	public TB_ProductPropertyItem(
		@lombok.NonNull TB_ProductPropertyItem bean
	) {
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setName(bean.getName());
		this.setComment(bean.getComment());
		this.setState(bean.getState());
		this.setCreator(bean.getCreator());
		this.setLastModifier(bean.getLastModifier());
		this.setProductProperty(bean.getProductProperty());
		this.setProducts(bean.getProducts());
		this.setMin(bean.getMin());
		this.setMax(bean.getMax());
		this.setProductCategoryPropertyItems(bean.getProductCategoryPropertyItems());
	}
	
	

	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("名称")
	@com.lianjing.sh.processing.info.annotation.InfoComment("名称")
	@javax.persistence.Column(name="name", unique=true, nullable=false, length=30)
	private String name;

	@com.lianjing.sh.model.common.annotation.Comment("备注")
	@com.lianjing.sh.processing.info.annotation.InfoComment("备注")
	@javax.persistence.Column(name="comment", length=255)
	private String comment;

	@com.lianjing.sh.model.common.annotation.Comment("状态")
	@com.lianjing.sh.processing.info.annotation.InfoComment("状态")
	@javax.persistence.Enumerated(javax.persistence.EnumType.STRING)
	@javax.persistence.Column(name="state", nullable=false)
	private com.lianjing.sh.model.uml.model.status.State_UpDown state;

	@com.lianjing.sh.model.common.annotation.Comment("创建者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("创建者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="creator_id", nullable=false)
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_Admin creator;

	@com.lianjing.sh.model.common.annotation.Comment("最后修改者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("最后修改者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="lastModifier_id", nullable=false)
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_Admin lastModifier;

	@com.lianjing.sh.model.common.annotation.Comment("产品属性")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品属性")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_ProductProperty productProperty;

	@com.lianjing.sh.model.common.annotation.Comment("产品")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToMany(mappedBy="productPropertyItems")
	private java.util.List<bairui.international.model.domain.jpa.TB_Product> products;

	@com.lianjing.sh.model.common.annotation.Comment("最小值")
	@com.lianjing.sh.processing.info.annotation.InfoComment("最小值")
	@javax.persistence.Column(name="min", nullable=false)
	private Double min;

	@com.lianjing.sh.model.common.annotation.Comment("最大值")
	@com.lianjing.sh.processing.info.annotation.InfoComment("最大值")
	@javax.persistence.Column(name="max", nullable=false)
	private Double max;

	@com.lianjing.sh.model.common.annotation.Comment("产品分类属性项")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品分类属性项")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.OneToMany(mappedBy="productPropertyItem")
	private java.util.List<bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem> productCategoryPropertyItems;

	/** get[名称] */
	public String getName() {
		return this.name;
	}

	/** get[备注] */
	public String getComment() {
		return this.comment;
	}

	/** get[状态] */
	public com.lianjing.sh.model.uml.model.status.State_UpDown getState() {
		return this.state;
	}

	/** get[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin getCreator() {
		return this.creator;
	}

	/** get[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin getLastModifier() {
		return this.lastModifier;
	}

	/** get[产品属性] */
	public bairui.international.model.domain.jpa.TB_ProductProperty getProductProperty() {
		return this.productProperty;
	}

	/** get[产品] */
	public java.util.List<bairui.international.model.domain.jpa.TB_Product> getProducts() {
		return this.products;
	}

	/** get[最小值] */
	public Double getMin() {
		return this.min;
	}

	/** get[最大值] */
	public Double getMax() {
		return this.max;
	}

	/** get[产品分类属性项] */
	public java.util.List<bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem> getProductCategoryPropertyItems() {
		return this.productCategoryPropertyItems;
	}

	/** set[名称] */
	public void setName(String name) {
		this.name = name;
	}

	/** set[备注] */
	public void setComment(String comment) {
		this.comment = comment;
	}

	/** set[状态] */
	public void setState(com.lianjing.sh.model.uml.model.status.State_UpDown state) {
		this.state = state;
	}

	/** set[创建者] */
	public void setCreator(bairui.international.model.domain.jpa.TB_Admin creator) {
		this.creator = creator;
	}

	/** set[最后修改者] */
	public void setLastModifier(bairui.international.model.domain.jpa.TB_Admin lastModifier) {
		this.lastModifier = lastModifier;
	}

	/** set[产品属性] */
	public void setProductProperty(bairui.international.model.domain.jpa.TB_ProductProperty productProperty) {
		this.productProperty = productProperty;
	}

	/** set[产品] */
	public void setProducts(java.util.List<bairui.international.model.domain.jpa.TB_Product> products) {
		this.products = products;
	}

	/** set[最小值] */
	public void setMin(Double min) {
		this.min = min;
	}

	/** set[最大值] */
	public void setMax(Double max) {
		this.max = max;
	}

	/** set[产品分类属性项] */
	public void setProductCategoryPropertyItems(java.util.List<bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem> productCategoryPropertyItems) {
		this.productCategoryPropertyItems = productCategoryPropertyItems;
	}



	public void assignProductProperty(bairui.international.model.domain.jpa.TB_ProductProperty productProperty) {
		if(null != productProperty){
			productProperty.addProductPropertyItems(this);
		}
		this.setProductProperty(productProperty);
	}
	



	/** add[Products] */
	public TB_ProductPropertyItem addProducts(bairui.international.model.domain.jpa.TB_Product ... products){
		if(this.products == null){
			this.products = new java.util.ArrayList<>();
		}
		for(bairui.international.model.domain.jpa.TB_Product bean : products){
			this.products.add(bean);
		}
		return this;
	}
	/** add[ProductCategoryPropertyItems] */
	public TB_ProductPropertyItem addProductCategoryPropertyItems(bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem ... productCategoryPropertyItems){
		if(this.productCategoryPropertyItems == null){
			this.productCategoryPropertyItems = new java.util.ArrayList<>();
		}
		for(bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem bean : productCategoryPropertyItems){
			bean.setProductPropertyItem(this);
			this.productCategoryPropertyItems.add(bean);
		}
		return this;
	}
	
	/** remove[Products] */
	public TB_ProductPropertyItem removeProducts(bairui.international.model.domain.jpa.TB_Product ... products){
		if(this.products == null){
			return this;
		}
		for(bairui.international.model.domain.jpa.TB_Product bean : products){
			this.products.remove(bean);
		}
		return this;
	}
	/** remove[ProductCategoryPropertyItems] */
	public TB_ProductPropertyItem removeProductCategoryPropertyItems(bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem ... productCategoryPropertyItems){
		if(this.productCategoryPropertyItems == null){
			return this;
		}
		for(bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem bean : productCategoryPropertyItems){
			bean.setProductPropertyItem(null);
			this.productCategoryPropertyItems.remove(bean);
		}
		return this;
	}
	
	/**
	 * contains[Products]
	 *
	 * 全部输入都包含：返回 true
	 * 输入中有至少有一个不包含：返回 false
	 */
	public boolean containsProducts(bairui.international.model.domain.jpa.TB_Product ... products){
		if(this.products == null || products==null || products.length<=0){
			return false;
		}
		return this.products.containsAll(java.util.Arrays.asList(products));
	}
	/**
	 * contains[ProductCategoryPropertyItems]
	 *
	 * 全部输入都包含：返回 true
	 * 输入中有至少有一个不包含：返回 false
	 */
	public boolean containsProductCategoryPropertyItems(bairui.international.model.domain.jpa.TB_ProductCategoryPropertyItem ... productCategoryPropertyItems){
		if(this.productCategoryPropertyItems == null || productCategoryPropertyItems==null || productCategoryPropertyItems.length<=0){
			return false;
		}
		return this.productCategoryPropertyItems.containsAll(java.util.Arrays.asList(productCategoryPropertyItems));
	}
	

	/** take[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin takeCreator(){
		if(null == this.creator){
			this.creator = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.creator;
	}
	
	/** take[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin takeLastModifier(){
		if(null == this.lastModifier){
			this.lastModifier = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.lastModifier;
	}
	
	/** take[产品属性] */
	public bairui.international.model.domain.jpa.TB_ProductProperty takeProductProperty(){
		if(null == this.productProperty){
			this.productProperty = new bairui.international.model.domain.jpa.TB_ProductProperty();
		}
		return this.productProperty;
	}
	
	/** must[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin mustCreator() {
		return this.creator;
	}
	
	/** must[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin mustLastModifier() {
		return this.lastModifier;
	}
	
	/** must[产品属性] */
	public bairui.international.model.domain.jpa.TB_ProductProperty mustProductProperty() {
		return this.productProperty;
	}
	
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_ProductPropertyItem other = (TB_ProductPropertyItem) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		String name = this.getName();
		if(null != name){
			return String.valueOf(name);
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setCreateTime(new java.util.Date());
		this.setModifyTime(new java.util.Date());
		this.setCreator((bairui.international.model.domain.jpa.TB_Admin)user);
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setModifyTime(new java.util.Date());
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}

	/**
	 * 状态相关
	 */
	public com.lianjing.sh.model.uml.model.status.State_UpDown state(){
		return this.getState();
	}


}
